<?
/************code by seven****************/
require("../../common/init.php");
require("author.php");
require("upfile.php");

$gee_cate=$product_category; // gee, 意为赶车时候喊的"驾", 此处用来表示次页面的主角对象
$gee_product = $product;

$do = $_GET['do'];
$id=0; if (isset($_GET["id"])) $id = $_GET["id"];

switch($do){
    case 'cate_add':
        add_cate();
        break;
    case 'cate_cancel':
        delete();
        break;

}

// sql action / sql 动作
function add_cate(){
    global $gee_cate;
    $id = $_POST['id'];
    $discount_type = $_POST['discount_type'];
    $discount_type_name = $_POST['discount_type_name'];
    $discount_value = $_POST['discount_value'];
    $promotion_id = $_POST['promotion_id'];
    $arr=array(
        'discount_type'=>$discount_type,
        'promotion_id' => $promotion_id,
        'discount_value' => $discount_value,
    );
    //pre($arr); exit;
    $gee_cate->update($arr, 'id', $id );
    $arr['discount_value'] = sprintf("%.2f", $arr['discount_value']);
    $arr['discount_type_name'] = $discount_type_name;
    echo json_encode($arr);
    // wheel("$url.php?promotion_id=".$promotion_id);
}

function delete()
{
    global $gee_cate, $id;
    $discount_type = 0;
    $discount_type_name = '';
    $discount_value = 0;
    $promotion_id = 0;
    $arr=array(
        'discount_type'=>$discount_type,
        'promotion_id' => $promotion_id,
        'discount_value' => $discount_value,
    );
    //pre($arr); exit;
    $gee_cate->update($arr, 'id', $id );
    $arr['discount_value'] = sprintf("%.2f", $arr['discount_value']);
    $arr['discount_type_name'] = $discount_type_name;
    echo json_encode($arr);
//echo $id;
}

// end article.php
